package com.ubxtech.core.hashring;

import lombok.Data;

/**
 * @author Victor.Xiao
 * @since 2023-12-09 17:04
 **/
@Data
public class ServiceNode {
    public String serviceId;
    /** 虚拟节点作为真实节点的副本 虚拟节点用ServiceId+"-"+replicaIndex拼接    */
    public Integer replicaIndex;

    public String getVirtualServiceId() {
        return serviceId +"-"+replicaIndex;
    }

    /**
     * 相等就是真实节点
     * @author Victor.Xiao
     * @since 2023-12-09 17:15
     * @param curServiceId curServiceId
     * @return boolean
    */
    public boolean virtualNodeFlag(String curServiceId) {
        return serviceId.equalsIgnoreCase(curServiceId);
    }
}
